package com.leoren.run.utils;

import java.math.BigDecimal;

/**
 * @ClassName MyNumberUtils
 * @Auther Leoren
 * @Date 2020/1/30 18:45
 * @Desc :
 * @Version v1.0
 **/

/**
 * 数字Util
 */
public class MyNumberUtils {


    public static float GetLatLngFormat(float f){
        int   scale  =   5;//设置位数
        int   roundingMode  =  4;//表示四舍五入，可以选择其他舍值方式，例如去尾，等等.
        BigDecimal bd  =   new  BigDecimal((double)f);
        bd   =  bd.setScale(scale,roundingMode);
        f   =  bd.floatValue();
        return f;
    }

    public static void main(String[] args) {
        System.out.println(getDistanceKMFromM(113555));
    }


    public static float GET2Point(float aveDiatance) {
        BigDecimal b = new BigDecimal(aveDiatance);
        return b.setScale(2, BigDecimal.ROUND_HALF_DOWN).floatValue();

    }

    public static float getDistanceKMFromM(int distance) {
        float f = distance /1000;
        return GET2Point(f);

    }
}
